package com.runa.persistence.service;

import com.runa.monitor.comm.entity.CommMeter;
import com.runa.monitor.comm.entity.CommNetEquipment;
import com.runa.monitor.comm.entity.CommPanel;
import com.runa.monitor.comm.entity.CommValve;
import com.runa.persistence.cache.CommMeterCache;
import com.runa.persistence.cache.CommNetEquipmentCache;
import com.runa.persistence.cache.CommPanelCache;
import com.runa.persistence.cache.CommValveCache;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * 2025/3/28 14:16
 * zhangYB
 */
@Slf4j
@Service
public class CommNetEquipmentService {

    @Resource
    private CommNetEquipmentCache commNetEquipmentCache;
    @Resource
    private CommMeterCache commMeterCache;
    @Resource
    private CommPanelCache commPanelCache;
    @Resource
    private CommValveCache commValveCache;


    public CommMeter getCommMeter(String netSerial, String meterSerial) {
        CommNetEquipment commNetEquipment = commNetEquipmentCache.getCommNetEquipmentBySerial(netSerial);
        if (null == commNetEquipment) {
            return null;
        }
        return commMeterCache.getCommMeterByNetEquIdAndSerial(commNetEquipment.getId(), meterSerial);
    }


    public CommValve getCommValve(String netSerial, String valveSerial) {
        CommNetEquipment commNetEquipment = commNetEquipmentCache.getCommNetEquipmentBySerial(netSerial);
        if (null == commNetEquipment) {
            return null;
        }
        return commValveCache.getCommValveByNetEquIdAndSerial(commNetEquipment.getId(), valveSerial);
    }


    public CommPanel getCommPanel(String netSerial, String panelSerial) {
        CommNetEquipment commNetEquipment = commNetEquipmentCache.getCommNetEquipmentBySerial(netSerial);
        if (null == commNetEquipment) {
            return null;
        }
        return commPanelCache.getCommPanelByNetEquIdAndSerial(commNetEquipment.getId(), panelSerial);
    }

}
